import UserAPI from "@/api/system/user.api";
import RoleAPI from "@/api/system/role.api";
import type { UserPageQuery } from "@/api/system/user.api";
import type { IContentConfig } from "@/components/CURD/types";

const contentConfig: IContentConfig<UserPageQuery> = {
  pageName: "sys:user",
  table: {
    border: true,
    highlightCurrentRow: true,
  },
  pagination: {
    background: true,
    layout: "prev,pager,next,jumper,total,sizes",
    pageSize: 20,
    pageSizes: [10, 20, 30, 50],
  },
  indexAction: function (params) {
    return UserAPI.getPage(params);
  },
  deleteAction: UserAPI.deleteByIds,
  importAction(file) {
    return UserAPI.import(1, file);
  },
  exportAction: UserAPI.export,
  importTemplate: UserAPI.downloadTemplate,
  importsAction(data) {
    // 模拟导入数据
    console.log("importsAction", data);
    return Promise.resolve();
  },
  exportsAction: async function (params) {
    // 模拟获取到的是全量数据
    const res = await UserAPI.getPage(params);
    console.log("exportsAction", res.list);
    return res.list;
  },
  pk: "id",
  toolbar: [
    "add",
    // "delete",
    // "import",
    // "export",
    // {
    //   name: "custom1",
    //   icon: "plus",
    //   text: "自定义1",
    //   auth: "import",
    //   type: "info",
    // },
  ],
  // defaultToolbar: ["refresh", "filter", "imports", "exports", "search"],
  cols: [
    { type: "selection", width: 50, align: "center" },
    { label: "预案ID", align: "center", prop: "id", width: 100, show: true },
    { label: "预案名称", align: "center", prop: "username" },
    { label: "预案描述", align: "center", prop: "avatar", templet: "image" },
    { label: "预案等级", align: "center", prop: "nickname", width: 120 },
    { label: "预案类型", align: "center", prop: "nickname", width: 120 },
    {
      label: "预案状态",
      align: "center",
      prop: "gender",
      width: 100,
      templet: "custom",
      slotName: "gender",
    },
    { label: "处理人", align: "center", prop: "deptName", width: 120 },

    { label: "发现日期", align: "center", prop: "createTime", width: 180 },
    { label: "处理日期", align: "center", prop: "createTime", width: 180 },
    {
      label: "操作",
      align: "center",
      fixed: "right",
      width: 280,
      templet: "tool",
      operat: [
        {
          icon: "Document",
          name: "detail",
          text: "详情",
        },
        "edit",
        "delete",
      ],
    },
  ],
};

export default contentConfig;
